package com.bms.cfcmms.service.authority;

import com.bms.cfcmms.model.system.module.Module;
import com.bms.cfcmms.dao.authority.RoleGroupDao;
import com.bms.cfcmms.model.system.authority.RoleGroup;
import com.bms.cfcmms.service.BaseService;
import org.springframework.stereotype.Service;

import java.util.List;

import javax.annotation.Resource;

/**
 * Created by carl on 2016/8/4.
 */
@Service
public class RoleGroupService extends BaseService<RoleGroup>{

    @Resource
    private RoleGroupDao roleGroupDao;

    public RoleGroup queryForObjectById(Object id) {
        Module module = queryModule();
        return roleGroupDao.queryForObjectById(id, module);
    }

    public Integer saveRoleGroup(RoleGroup roleGroup){
        Module module = queryModule();
        String tableName = module.getTableName();
        return roleGroupDao.save(roleGroup, tableName);
    }

    public Integer updateRoleGroup(RoleGroup roleGroup){
        Module module = queryModule();
        return roleGroupDao.updateEntity(roleGroup, module);
    }

    public Integer deleteRoleGroupById(String roleGroupId){
        Module module = queryModule();
        return roleGroupDao.delete(roleGroupId, module);
    }

    public Integer deleteRoleGroupBySelected(List<String> ids) {
        for (String id : ids) {
            this.deleteRoleGroupById(id);
        }
        return ids.size();
    }
}
